package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HousesMapper;
import com.ruoyi.system.domain.Houses;
import com.ruoyi.system.service.IHousesService;

/**
 * 出租的房屋Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-30
 */
@Service
public class HousesServiceImpl implements IHousesService 
{
    @Autowired
    private HousesMapper housesMapper;

    /**
     * 查询出租的房屋
     * 
     * @param id 出租的房屋主键
     * @return 出租的房屋
     */
    @Override
    public Houses selectHousesById(Long id)
    {
        return housesMapper.selectHousesById(id);
    }

    /**
     * 查询出租的房屋列表
     * 
     * @param houses 出租的房屋
     * @return 出租的房屋
     */
    @Override
    public List<Houses> selectHousesList(Houses houses)
    {
        return housesMapper.selectHousesList(houses);
    }

    /**
     * 微信查询出租的房屋列表
     *
     * @param houses 出租的房屋
     * @return 出租的房屋
     */
    @Override
    public List<Houses> wxHousesList(Houses houses)
    {
        return housesMapper.wxHousesList(houses);
    }

    /**
     * 根据经续度查询出租的房屋列表
     * 以1公里为距离范围内
     * @param lat 续度
     * @param lng 经度
     * @param distance 距离
     * @return 出租的房屋集合
     */
    public List<Houses> selectHousesByLatLng(Double lat,Double lng,Double distance)
    {
        return housesMapper.selectHousesByLatLng(lat,lng,distance);
    }

    /**
     * 新增出租的房屋
     * 
     * @param houses 出租的房屋
     * @return 结果
     */
    @Override
    public int insertHouses(Houses houses)
    {
        houses.setCreateTime(DateUtils.getNowDate());
        return housesMapper.insertHouses(houses);
    }

    /**
     * 修改出租的房屋
     * 
     * @param houses 出租的房屋
     * @return 结果
     */
    @Override
    public int updateHouses(Houses houses)
    {
        houses.setUpdateTime(DateUtils.getNowDate());
        return housesMapper.updateHouses(houses);
    }

    /**
     * 批量删除出租的房屋
     * 
     * @param ids 需要删除的出租的房屋主键
     * @return 结果
     */
    @Override
    public int deleteHousesByIds(Long[] ids)
    {
        return housesMapper.deleteHousesByIds(ids);
    }

    /**
     * 删除出租的房屋信息
     * 
     * @param id 出租的房屋主键
     * @return 结果
     */
    @Override
    public int deleteHousesById(Long id)
    {
        return housesMapper.deleteHousesById(id);
    }
    @Override
    public boolean updateHouseStatus(Long id, String status) {
        int rows = housesMapper.updateStatusById(id, status);
        return rows > 0;
    }
}
